package org.awenlice.playerdailyshop.client;

import net.minecraft.client.Minecraft;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import org.awenlice.playerdailyshop.gui.BuyShopGui;
import org.awenlice.playerdailyshop.gui.ShopGui;
import org.awenlice.playerdailyshop.network.OpenBuyShopPacket;
import org.awenlice.playerdailyshop.network.OpenSellShopPacket;
import org.awenlice.playerdailyshop.network.PacketHandler;

@OnlyIn(Dist.CLIENT)
@Mod.EventBusSubscriber(modid = "playerdailyshop", value = Dist.CLIENT)
public class KeyInputHandler {
    @SubscribeEvent
    public static void onKeyInput(InputEvent.Key event) {
        Minecraft minecraft = Minecraft.getInstance();
        if (minecraft.player != null) {
            if (KeyBindings.OPEN_SELL_SHOP.isDown()) {
                // 发送数据包到服务端
                PacketHandler.INSTANCE1.sendToServer(new OpenSellShopPacket());
            }
            if (KeyBindings.OPEN_BUY_SHOP.isDown()) {
                // 发送数据包到服务端
                PacketHandler.INSTANCE2.sendToServer(new OpenBuyShopPacket());
            }
        }
    }
}